package com.zhuangwei;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

/**
 * soring boot 集成 themeleaf
 *
 * @author LeviCoder
 * @create 2019-01-28 19:18
 */
@SpringBootApplication
@Controller
public class SpringBootThymeleafApplication
{
    public static void main(String[] args)
    {
        SpringApplication.run(SpringBootThymeleafApplication.class, args);
    }

    @GetMapping({"", "/"})
    public ModelAndView index(@RequestParam(defaultValue = "thymeleaf") String name)
    {
        ModelAndView view = new ModelAndView();
        view.addObject("name", name);
        view.setViewName("index");
        return view;
    }
}
